package com.yanqu.road.server.cmd.zhaoshang;

import com.yanqu.road.pb.zhaoshang.ZhaoShangProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.zhaoshang.ZsModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_ZS_PROJECT_RANK_LIST_FROM_CROSS, desc = "排行榜")
public class ZsWeekRankListCmdFromCross  extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ZhaoShangProto.ZsWeekRankListRespMsgFromCross crossRespMsg = ZhaoShangProto.ZsWeekRankListRespMsgFromCross.parseFrom(packet.getBytes());
        ZhaoShangProto.ZsWeekRankListRespMsg.Builder respMsg = ZhaoShangProto.ZsWeekRankListRespMsg.newBuilder();
        if(crossRespMsg.getMyRank() <= 0){
           long token = player.getModule(ZsModule.class).getUserTokenByType(crossRespMsg.getRankType());
           respMsg.setValue(String.valueOf(token));
        }else{
           respMsg.setValue(crossRespMsg.getValue());
        }
        respMsg.setRankType(crossRespMsg.getRankType());
        respMsg.setMyRank(crossRespMsg.getMyRank());
        respMsg.addAllRankList(crossRespMsg.getRankListList());
        player.sendPacket(Protocol.U_ZS_PROJECT_RANK_LIST, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
